#ifndef CIRCLEWIDGET_H
#define CIRCLEWIDGET_H

#include <QWidget>
#include <QPointF>
#include <QMouseEvent>
#include <QPainter>
#include <QtMath>

class CircleWidget : public QWidget
{
    Q_OBJECT

public:
    explicit CircleWidget(QWidget *parent = nullptr);
    ~CircleWidget();

protected:
    void paintEvent(QPaintEvent *event) override;
    void mousePressEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) override;

private:
    QPointF center;         // 圆心
    double radius;          // 半径长度
    double angle;           // 半径的角度（弧度）
    bool dragging;          // 是否正在拖动

    // 辅助函数
    bool isNearRadius(const QPointF &pos, double threshold = 10.0) const;

    // 用于绘制坐标轴箭头的辅助函数
    void drawArrow(QPainter &painter, int x, int y, bool isXAxis);
};

#endif // CIRCLEWIDGET_H
